/*
 * Copyright (C), 2002-2014, 
 * FileName: //文件名
 * Author:   Administrator
 * Date:     2014年12月19日 下午3:57:49
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.deco.back.controller.brand;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.deco.domain.vo.brand.ActivityReportVo;
import com.deco.domain.vo.brand.BrandStoryVo;
import com.deco.service.brand.BrandStoryService;
import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;
import com.free.common.vo.ResultModel;
import com.free.ext.web.spring.annoation.PageSearch;

/**
 * 品牌故事Controller
 * 
 * @author xxg
 */
@Controller
public class BrandStoryController {

    @Autowired
    private BrandStoryService brandStoryService;

    /**
     * View视图
     */
    @RequestMapping(value="/brand_story_list")
    public ModelAndView brandstoryList() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("brand/brandstorylist");
        return modelAndView;
    }
    
    @RequestMapping(value= "/brandstory/pageInfo")
    @ResponseBody
    public PageResponseVo<BrandStoryVo> getList(@PageSearch PageSearchVo<BrandStoryVo> condition){
        return brandStoryService.pageInfo(condition);
    }
    
    /**
     * View视图
     */
    @RequestMapping(value="/brand_story_edit")
    public ModelAndView activeEdit(HttpServletRequest req,Integer id) {
    	 ModelAndView mv = new ModelAndView("brand/brandstoryedit");
    	 BrandStoryVo vo = null;
    	 if(id != null){
    		vo =  brandStoryService.getBrandStory(id);
            mv.addObject("actNm","更新");
    	}
    	 else{
    	     vo = new BrandStoryVo();
    	     vo.setId(0);
             mv.addObject("actNm","新增");
    	 }
        mv.addObject("obj", vo);
        return mv;
    }
    
    
    
    /**
     *  保存更新品牌故事
     * @param req
     * @param activeReportVo
     * @return
     */
    @RequestMapping(value="/brand_story_edit_submit.do")
    @ResponseBody
    public ResultModel editSubmit(HttpServletRequest req ,BrandStoryVo brandStoryVo) {
    	
    	return brandStoryService.save(brandStoryVo);
    }
    
    /**
     *  
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/brandstory/batchdelete")
    public ResultModel batchDelete(HttpServletRequest request) {
    	String ids = request.getParameter("ids");
    	String[] idArray =  ids.split(",");

    	return brandStoryService.batchDelete(idArray);
    }
    
    /**
     *  
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/brandstory/delete")
    public ResultModel delete(HttpServletRequest request) {
    	int id = Integer.parseInt(request.getParameter("id"));

    	return brandStoryService.delete(id);
    }
    
    /**
     *  
     * @param req
     * @param activeReportVo
     * @return
     */
    @RequestMapping(value="/brandstory/save")
    @ResponseBody
    public ResultModel save(HttpServletRequest req ,BrandStoryVo brandStoryVo) {
    	return brandStoryService.save(brandStoryVo);
    }
    
}
